package com.sgb.kjwl.view.ui.adapter.transport;

import android.content.Context;
import android.text.TextUtils;
import android.widget.TextView;


import com.sgb.link.R;


import com.sgb.kjwl.model.entity.transport.AMapAddressEntity;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter2;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import java.util.List;

/**
 * Describe:
 * Author:  yangLei
 * Date:    2021/7/30
 */
public class RecommendAddressListAdapter extends BaseRecycleAdapter2<AMapAddressEntity> {
    public RecommendAddressListAdapter(Context context, List<AMapAddressEntity> data) {
        super(context, R.layout.recommend_address_list_item, data);
    }

    @Override
    public void convert(ItemViewHolder holder, AMapAddressEntity entity, int position) {
        if (!TextUtils.isEmpty(entity.getSnippet()))
            ((TextView) holder.itemView.findViewById(R.id.name)).setText(entity.getSnippet());

        StringBuilder details = new StringBuilder();
        if (!TextUtils.isEmpty(entity.getProvince())) {
            details.append(entity.getProvince());
        }
        if (!TextUtils.isEmpty(entity.getCity())) {
            details.append(entity.getCity());
        }
        if (!TextUtils.isEmpty(entity.getDistrict())) {
            details.append(entity.getDistrict());
        }
        if (!TextUtils.isEmpty(entity.getStreet())) {
            details.append(entity.getStreet());
        }
        ((TextView) holder.itemView.findViewById(R.id.address_details)).setText(details.toString());

    }
}
